package com.lebang.medicalInquiry.service;


import com.lebang.medicalInquiry.mapper.UserMapper;
import com.lebang.medicalInquiry.model.po.Article;
import com.lebang.medicalInquiry.model.po.Physician;
import com.lebang.medicalInquiry.model.po.User;
import com.lebang.medicalInquiry.model.vo.PageVo;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class UserService {

    @Resource
    private UserMapper userMapper;

    public PageVo<List<User>> getList(String keyWord, Integer state, String sex, Integer page, Integer limit) {
        List<User> list = userMapper.listByCondition(keyWord, state, sex, (page - 1) * limit, limit);
        Integer count = userMapper.countByCondition(keyWord, state, sex);
        return new PageVo<>(list, count);
    }

    public void operator(User po) {

        po.setUpdateTime(LocalDateTime.now());
        userMapper.updateByPrimaryKey(po);

    }
}
